package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.dispatch.domain.MiningTeam;
import com.ruoyi.dispatch.service.IMiningTeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回采队信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/dispatch/miningTeam")
@Anonymous
public class MiningTeamController extends BaseController
{
    @Autowired
    private IMiningTeamService dispatchMiningTeamService;

    /**
     * 查询回采队信息列表
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:miningteam:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiningTeam miningTeam)
    {
        startPage();
        List<MiningTeam> list = dispatchMiningTeamService.selectDispatchMiningTeamList(miningTeam);
        return getDataTable(list);
    }

    /**
     * 导出回采队信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:miningteam:export')")
    @Log(title = "回采队信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiningTeam miningTeam)
    {
        List<MiningTeam> list = dispatchMiningTeamService.selectDispatchMiningTeamList(miningTeam);
        ExcelUtil<MiningTeam> util = new ExcelUtil<MiningTeam>(MiningTeam.class);
        util.exportExcel(response, list, "回采队信息数据");
    }

    /**
     * 获取回采队信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:miningteam:query')")
    @GetMapping(value = "/{miningTeamId}")
    public AjaxResult getInfo(@PathVariable("miningTeamId") Long miningTeamId)
    {
        return success(dispatchMiningTeamService.selectDispatchMiningTeamByMiningTeamId(miningTeamId));
    }

    /**
     * 新增回采队信息
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:miningteam:add')")
    @Log(title = "回采队信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiningTeam miningTeam)
    {
        return toAjax(dispatchMiningTeamService.insertDispatchMiningTeam(miningTeam));
    }

    /**
     * 修改回采队信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:miningteam:edit')")
    @Log(title = "回采队信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiningTeam miningTeam)
    {
        return toAjax(dispatchMiningTeamService.updateDispatchMiningTeam(miningTeam));
    }

    /**
     * 删除回采队信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:miningteam:remove')")
    @Log(title = "回采队信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{miningTeamIds}")
    public AjaxResult remove(@PathVariable Long[] miningTeamIds)
    {
        return toAjax(dispatchMiningTeamService.deleteDispatchMiningTeamByMiningTeamIds(miningTeamIds));
    }
}
